package com.yutian.springbootwebflux.controller;

import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : cuixiuyin
 * @date : 2019/8/14
 */
@Controller
public class WelcomeController {

    /**
     * http://localhost:8099/webflux/welcome，后端渲染显示resources/templates/welcome.ftl
     * @return
     */
    @GetMapping("/welcome")
    public String welcome(Model model) {
        model.addAttribute("who", "you");
        return "welcome";
    }

    /**
     * http://localhost:8099/webflux/hello，返回字符串
     * @return
     */
    @GetMapping("/hello")
    @ResponseBody
    public String hello() {
        return "hi, hello";
    }
}